<?php namespace App\Models\Cxhshop;

use App\Models\Base\CxhshopBase;
use Illuminate\Support\Facades\DB;
class Car extends CxhshopBase { 
    protected $table = 'ims_cxh_car';
    //获取全部类型(车辆)
    public function getcar($condition=array(),$page=1,$number =10){ 
        $tid =  $condition['uid'];
        $filed = ['id','title','img','created_at','updated_at','name'];
        $query = self::query();
        $count = $query->where('tid','=',$tid)->forPage($page,$number)->orderBy('created_at','desc')->get($filed)->count();
        if($count>0){
            $date =$query->where('tid','=',$tid)->forPage($page,$number)->orderBy('created_at','desc')->get($filed)->toArray();
            return $date;
        }else{
            return false;
        }
    }

    public function getcartype($conditon =array(),$page=1,$number =10){
        $count = DB::connection('jmft_cxh')->table('ims_cxh_cartype')->forPage($page,$number)->get()->count();
        if($count>0){
            $data =DB::connection('jmft_cxh')->table('ims_cxh_cartype')->forPage($page,$number)->get();
            $data = json_decode($data,true);
            return $data;
        }else{
            return false;
        }
    }

   

}